package com.itheima.mapper;

import com.itheima.pojo.Role;
import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

@Mapper
public interface UserMapper {
    /**
     * 根据用户名查询用户
     * @param username
     * @return
     */
    @Select("select * from t_user where username=#{username}")
    User getByUsername(String username);

    /**
     * 根据用户id查询角色
     * @param id
     * @return
     */
    @Select("select * from t_role where id in (select role_id from t_user_role where user_id=#{id})")
    List<Role> getRolesByUserId(Integer id);
}
